
import type { GetPatientConsultOrderDetailDatas, GetPatientOrderLogisticsData, MedicineOrderDetail, MedicineOrderPre, PostPatientMedicineOrderParams } from '@/types/order'
import { request } from '@/utils/request'

/**
 * 获取药品预支付信息
 * @param id 处方ID
 * @returns
 */
export const getPatientMedicineOrderPreAPI = (id: string) => {
  return request<MedicineOrderPre>('/patient/medicine/order/pre', 'GET', {
    prescriptionId: id,
  })
}


/**
 * 提交药品订单
 * @param data 提交药品订单参数
 * @returns 订单ID
 */
export const postPatientMedicineOrderAPI = (data: PostPatientMedicineOrderParams) => {
  return request<{ id: string }>('/patient/medicine/order', 'POST', data)
}

/**
 * 获取药品订单详情
 * @param id 订单ID
 * @returns
 */
export const getPatientMedicineOrderDetailAPI = (id: string) => {
  return request<MedicineOrderDetail>(`/patient/medicine/order/detail/${id}`, 'GET')
}

/**
 * 取消药品订单
 * @param id 订单ID
 * @returns
 */
export const cancelPatientMedicineOrderAPI = (id: string) => {
  return request(`/patient/order/cancel/${id}`, 'PUT')
}

/**
 * 删除药品订单
 * @param id 订单ID
 * @returns
 */
export const deletePatientMedicineOrderAPI = (id: string) => {
  return request(`/patient/order/${id}`, 'DELETE')
}

/**
 * 问诊-查询订单详情信息-找医生、极速问诊和开药问诊
 */
export const getPatientConsultOrderDetailAPI = (orderId: string) => {
  return request<GetPatientConsultOrderDetailDatas>('/patient/consult/order/detail', 'GET', {
    orderId
  })
}

/**
 * 查询物流信息
 * @param id 订单ID
 * @returns
 */
export const getPatientOrderLogisticsByIdAPI = (id: string) => {
  return request<GetPatientOrderLogisticsData>(`/patient/order/${id}/logistics`, 'GET')
}
